﻿using LoginModule.ViewModels;
using LoginModule.Views;
using Microsoft.EntityFrameworkCore;
using Prism.Ioc;
using Prism.Modularity;
using LoginModule.DbContexts;
namespace LoginModule {
    public class LoginProfile : IModule {
        public void OnInitialized(IContainerProvider containerProvider) {

        }

        public void RegisterTypes(IContainerRegistry containerRegistry) {
            containerRegistry.RegisterForNavigation<LoginUC, LoginUCViewModel>();
            
            //注册数据库上下文
            containerRegistry.RegisterScoped<LoginDbContext>(provider => {
                var optionsBuilder = new DbContextOptionsBuilder<LoginDbContext>();
                optionsBuilder.UseSqlite("Data Source=D:\\Projects\\sqlite\\login.db;");
                return new LoginDbContext(optionsBuilder.Options);
            });
        }
    }
}